#version 430 core

#define LOC_X 16
#define LOC_Y 16

#define GRID_SIZE_X 64
#define GRID_SIZE_Y 64

layout(local_size_x=LOC_X, local_size_y=LOC_Y) in;

layout(binding=0, r32f) uniform readonly image2D levelSetImage;
layout(binding=1, rgba32f) uniform writeonly image2D jumpFloodingImage;

void main(void)
{
	ivec2 gid = ivec2(gl_GlobalInvocationID.xy);
	if (gid.x <= GRID_SIZE_X && gid.y <= GRID_SIZE_Y)
	{
		if (imageLoad(levelSetImage, gid).x <= 0.f)
		{
			imageStore(jumpFloodingImage, gid, vec4(0.0, gid.x, gid.y, 1.f));
		}
	}
}